home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / MFLMS.DOC < prev    next >
Text File  |  1989-11-25  |  45KB  |  1,268 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                           ==============================
  14.                           = MICROFIRM FUNCTION LIBRARY =
  15.                           = for Microsoft C & Quick C  =
  16.                           =          - by -            =
  17.                           =         Bob Stout          =
  18.                           ==============================
  19.  
  20.  
  21.                   Functions and Documentation Copyright 1988-89
  22.                          by Robert B. Stout dba MicroFirm
  23.  
  24.                  Portions Copyright 1986-87 by Steven E. Margison
  25.  
  26.                              -- All Rights Reserved --
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.                       --------- TABLE OF CONTENTS ---------
  74.  
  75.  
  76.               Introduction ................................. 1
  77.               The Documentation ............................ 1
  78.               Installation ................................. 2
  79.               Linking ...................................... 3
  80.               Real Time Interrupt Handler .................. 4
  81.               Video Functions .............................. 5
  82.                  A.  Introduction .......................... 5
  83.                  B.  Initialization ........................ 5
  84.                  C.  De-Initialization ..................... 6
  85.                  D.  Cursor and Character Placement ........ 6
  86.                  E.  Writing Characters and Attributes ..... 7
  87.                  F.  Miscellaneous Operations .............. 7
  88.                  G.  Video Page Switching .................. 8
  89.                  H.  Reading from Video Memory ............. 9
  90.               Utilities .................................... 10
  91.               Rebuilding Libraries.......................... 13
  92.               "We Get Letters" ............................. 14
  93.               Shareware & Online Help ...................... 17
  94.               Warranty ..................................... 20
  95.               Registration Form ............................ --
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.                 MicroFirm Function Library for Microsoft C & Quick C
  138.  
  139.  
  140.          I. INTRODUCTION
  141.  
  142.                  The heart  of  the  C  language  is  its  library.  Each
  143.          compiler has its own library of  functions,  which  is  complete
  144.          only  to  the degree that the compiler author wishes to make it.
  145.          The Microsoft C compilers are excellent products,  and come with
  146.          a very  extensive  function libraries  which  have all the usual
  147.          "standard" functions, plus many DOS functions as well.  However,
  148.          the more functions a programmer has at his disposal, the shorter
  149.          the  time  from  idea  to  complete  program.  That's where  The
  150.          Microfirm Function Library comes in.  With over 200 functions it
  151.          greatly enhances program development with Microsoft C & Quick C.
  152.  
  153.                  The  MicroFirm Function Library  has  an  entire  set of
  154.          direct  video  functions  originally  written  for  the  Turbo C
  155.          compiler,  and modeled after similar functions supplied with the
  156.          Zortech  and  earlier  Datalight C compilers.  Even though  many
  157.          compiler  vendors  now offer  direct  video access packages, the
  158.          MicroFirm Function Library's is an attractive alternative.
  159.  
  160.  
  161.  
  162.  
  163.          II. THE DOCUMENTATION
  164.  
  165.                  The  documentation  for  the library is contained in the
  166.          file, MFL_FUNC.MAN, which describes each function.   A companion
  167.          quick reference,  MFL_QREF.DOC, is also provided  which  briefly
  168.          lists   the  prototypes  and  functional  descriptions  for  all
  169.          lirary functions. Additional documentation includes TKNOTES.DOC,
  170.          containing  technical  notes  on  the 1.01 release, README which
  171.          contains  miscellaneous  information  along  with  changes  from
  172.          previous versions, and CREDITS wherein the folks who helped make
  173.          this library a reality are given proper recognition.
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.         MicroFirm Function Library for Microsoft C & Quick C          Page 1
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.          III. INSTALLATION
  216.  
  217.          The  MicroFirm  Function  Library is distributed as five library
  218.          files for each type of memory model. (Only the full registration
  219.          with source has all five libraries. The filenames are:
  220.  
  221.               MFLMSS.LIB       Small Memory Model
  222.               MFLMSC.LIB       Compact Memory Model
  223.               MFLMSM.LIB       Medium Memory Model
  224.               MFLMSH.LIB       Huge Memory Model
  225.               MFLMSL.LIB       Large Memory Model
  226.  
  227.          For  the remainder of this manual the libraries will be referred
  228.          to as MFLMSx.LIB.
  229.  
  230.          A typical hard disk installation of  Microsoft C or Quick C will
  231.          consist  of  several  directories, one of which will contain all
  232.          the "include" files  (those with  ".H"  extensions) and one with
  233.          the library files (those with ".LIB" extensions).   All files in
  234.          The MicroFirm Function Library" with an ".H" extension should be
  235.          placed  in  the directory with the other ".H" files.  Similarly,
  236.          all  MicroFirm  Function  Library  files with a ".LIB" extension
  237.          should be placed with the other ".LIB" files.  The documentation
  238.          and  source  files  from  The MicroFirm Function Library" do not
  239.          need to be on the hard disk, as they will only be used to  print
  240.          the  documentation or  modify the function source.  They are not
  241.          used  in  the  creation  of a program.  The executable utilities
  242.          (*.EXE) files supplied with The MicroFirm  Function  Library may
  243.          be  optionally  placed in any directory  specified in your  PATH
  244.          environment.  These programs are  all examples of function usage
  245.          and  C  programming,  and  do  not directly  relate  to  program
  246.          development.  However, they  are  useful and should be placed on
  247.          your system for access.
  248.  
  249.          The files in The MicroFirm Function Library with an extension of
  250.          ".BAT", ".MFL" or ".MAC" are required only for re-assembling the
  251.          assembly language  modules  from this library.  They do not need
  252.          to be placed on your hard disk unless you  plan  to  re-assemble
  253.          any ".ASM" source code files.
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.         MicroFirm Function Library for Microsoft C & Quick C          Page 2
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.          IV. LINKING
  282.  
  283.                  The MFLMSx.LIB library must  be  linked  with  any other
  284.          libraries whenever  a  function  is  used in your program.  Some
  285.          programs may not use  MFLMSx.LIB  functions,  and  therefore the
  286.          linking of  the  library  may  be  eliminated  to save time.  In
  287.          addition, if you have other third party libraries,  be  sure  to
  288.          include them after MFLMSx.LIB.
  289.  
  290.                  There are several methods to invoke the MFLMSx.LIBs when
  291.          linking  under  Microsoft C  or  Quick C. Refer to your compiler
  292.          manual or on-line help for information  on  using  the libraries
  293.          either from the command line (using CL.EXE or QCL.EXE) or within
  294.          the QC programming environment.
  295.  
  296.                  MS  LINK.EXE  can link files with case-sensitivity on or
  297.          off.  With case off, the symbols foobar() and  FOOBAR() would be
  298.          considered the same.   With  case on,  they would  be different.
  299.          C  is  inherently  a  case  sensitive  language so, though it is
  300.          really  bad  form to name functions  or variables with identical
  301.          names but varying case, The MicroFirm Function Libraries are all
  302.          compiled and/or assembled with case-sensitivity enabled.
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.         MicroFirm Function Library for Microsoft C & Quick C          Page 3
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.          V. REAL TIME INTERRUPT HANDLER
  348.  
  349.          A  special  feature  of  The  MicroFirm Function Library  is the
  350.          "ticker" interrupt handler function.  This function provides the
  351.          programmer  with  the  ability  to  install a special routine to
  352.          intercept DOS interrupt 1CH. ticker()  is  a  pre-built  handler
  353.          which  allows  the  user  to  perform operations relative to the
  354.          system's clock.  A special variable may be loaded with  a  value
  355.          and then tested at intervals.  When the variable has hit zero, a
  356.          specific amount  of  time  has passed.  The variable counts 18.2
  357.          times per second, and is installed on INT 1CH.
  358.  
  359.                  The usage of this interrupt  handler  forces  some  hard
  360.          rules on  the  programmer.    Since this is an interrupt routine
  361.          which is called asynchronously to your  program,  it  ABSOLUTELY
  362.          MUST  be  un-installed  BEFORE  your program exits to DOS. To do
  363.          otherwise will invariably cause the next program  run  to  crash
  364.          the  system,  since  the 1CH interrupt will then be invoked to a
  365.          section of code in the new program which is NOT intended  to  be
  366.          run  from  int 1CH. Therefore, it is imperative to control exits
  367.          from your program when using the ticker.  This means  that  your
  368.          program   should   exit   from   only  one  place,  which  calls
  369.          removetick() before performing  the  actual  exit.    With  good
  370.          program  design,  this  is easy to accomplish. (Watch out for my
  371.          error(), cant(), badext(), and eraok() functions, though,  since
  372.          they  will  exit  the  program all by themselves!) What isn't so
  373.          obvious is the manner in which a program may exit beyond control
  374.          of the program itself.   This  is  done  if  the  user  types  a
  375.          control-break, or responds with (A)bort to a DOS critical error.
  376.          To  avoid  exiting  the  program  under these circumstances, any
  377.          program which uses the ticker MUST ALSO use Turbo-C's  ctrlbrk()
  378.          AND  harderr()  functions  to trap and cleanly process a program
  379.          exit.  The Turbo-C function  "atexit()"  can  also  be  used  to
  380.          insure  that the ticker is removed upon ANY program exit, and is
  381.          probably the  preferred  means  of  accomplishing  this.     The
  382.          function removetick() would be registered with atexit() in order
  383.          to insure it is called upon exit.
  384.  
  385.                  One  exception:  if  the program is a terminate and stay
  386.          resident (TSR) utility which needs interrupt  1CH  to  function,
  387.          then  removetick()  should  NOT  be  invoked  before  using  the
  388.          resident exit DOS command.
  389.  
  390.                  The ticker interrupt routine resolves time only to about
  391.          55 milliseconds.  For timings with finer resolutions,  the  8253
  392.          timer   chip   may   be  utilized  for  timings  to  microsecond
  393.          resolution.  Refer to the documentation on the  high  resolution
  394.          timer function, uclock().
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.         MicroFirm Function Library for Microsoft C & Quick C          Page 4
  402.  
  403.  
  404.  
  405.  
  406.  
  407.          VI. VIDEO FUNCTIONS
  408.                                  A. Introduction
  409.          The MicroFirm Function Library  provides a complete facility for
  410.          direct writes  and  reads in video memory.  Direct video memory,
  411.          dvid for short, provides the programmer with a means of creating
  412.          extremely fast screen displays, with full  control  over  colors
  413.          and attributes.    Virtually  all  good  programs, commercial or
  414.          otherwise, make use of direct video access to create the  rapid,
  415.          sparkling displays  that  attract  users.   There is one gotcha,
  416.          though.  Direct video access works only  on  systems  which  are
  417.          truly IBM  compatible.  Thankfully, this is almost every PC-type
  418.          system nowadays.  However, there still  may  be  the  occasional
  419.          wierdo  system  which places video memory at an oddball address.
  420.          With these systems, the direct  video  access  package  in  this
  421.          library will  fail.  However, since there is a BIOS override, it
  422.          should still be possible to configure a program to operate using
  423.          rom-bios services for those cases.
  424.                  Using dvid  is  very  simple,  but  carries  some  extra
  425.          responsibility  for  the  programmer,  especially if the program
  426.          being created is intended for public distribution.  Some  things
  427.          to consider are:
  428.               *  provision  for  forcing  black & white on a CGA, in
  429.               case the user has only a monochrome monitor
  430.               * provision for changing  the  default  colors.  (Just
  431.               because  YOU  like  magenta  text on a blue background
  432.               doesn't mean that everybody else does!)
  433.               * provision for forcing bios routines in case the user
  434.               has an oddball video system.
  435.               * sensing a monochrome adapter card (MDA) and altering
  436.               the  program  accordingly;   i.e.,   no   video   page
  437.               switching, and an underline attribute.
  438.                  Of  course,  you  can  always  specify that your program
  439.          requires a CGA only, or an MDA only, but it is  better  to  have
  440.          the ability to work with both if possible.  For the remainder of
  441.          this  discussion  it  may  be handy to have a printout of DUMP.C
  442.          (one of the supplied utilities) for  reference.    This  program
  443.          does not take into consideration user configuration, since it is
  444.          supplied in source  form.    Don't  like  the  colors?  Edit the
  445.          source and re-compile it!  As a matter  of  fact,  this  program
  446.          serves as  a  good  "test  bed"  for  the  dvid functions.  Many
  447.          modifications are possible to demonstrate the use  of  the  dvid
  448.          functions.
  449.  
  450.                                 B. Initialization
  451.                  Before  the  dvid functions can be used, the dvid_init()
  452.          function must  be  invoked.    This  function  investigates  the
  453.          system's  resources  and  sets the base video address, number of
  454.          rows, and  columns,  into  its  private  memory  area.      This
  455.          information is  critical to proper dvid operation.  Using any of
  456.          the functions before invoking dvid_init()  will  probably  cause
  457.          problems  on  MONO boards, and definitely cause trouble with CGA
  458.          or EGA boards.  If the initialization procedure  encounters  any
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.         MicroFirm Function Library for Microsoft C & Quick C          Page 5
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.          type of video information which it  cannot  understand,  then  a
  475.          flag is set and all video access through the system will then be
  476.          done  through  rom-bios  video  services, instead of directly to
  477.          memory.  Generally, the only effect of  this  will  be  to  make
  478.          screen writing noticably slower, but still not as slow as normal
  479.          text  writing  through DOS. In addition, it will NOT be possible
  480.          to display one CGA video page and  write  to  a  different  one.
  481.          However,  the  occasions  when  this  would occur should be very
  482.          rare.  There are ways to insure that EGA cards  will  behave  as
  483.          MONO or  CGA  cards.   By using the vmode() function you can set
  484.          the video  mode  desired  before  calling  dvid_init().    Then,
  485.          dvid_init() should obtain the correct mode from an EGA emulating
  486.          a CGA, and avoid setting the bios flag.
  487.                  dvid_init()  has  no  effect  if  called more than once,
  488.          since a check is made on an initialization flag.  Therefore,  it
  489.          is   not   possible  to  change  video  modes  and  then  recall
  490.          dvid_init().  In order  for  dvid_init()  to  re-initialize  the
  491.          video    system,   dvid_done()   must   first   be   called   to
  492.          "de-initialize"  the  video  system  and  restore  all  internal
  493.          defaults.
  494.  
  495.                                C. De-Initialization
  496.                  There  is  really  no  overwhelming  need  to  call  the
  497.          dvid_done() function, unless you just happen to be a "neat-nik".
  498.          dvid_done() updates the screen cursor position and restores  the
  499.          cursor shape  to  what  it was when dvid_init() was invoked.  In
  500.          addition, it will restore all  of  the  dvid  function  internal
  501.          parameters  to their default values and make possible the recall
  502.          of dvid_init().  Normally,  dvid_done()  would  be  called  just
  503.          prior to exiting the program.
  504.  
  505.                         D. Cursor and Character Placement
  506.                  The   dvid  system  maintains  two  sets  of  row/column
  507.          parameters.  The first indicates where the NEXT  character  will
  508.          be written  in the video memory.  The second stores the position
  509.          of the REAL onscreen cursor.  Since rom-bios routines  are  used
  510.          to  change  the  location  of  the  onscreen  cursor,  it is not
  511.          efficient to continually update the onscreen cursor for all dvid
  512.          write operations.  The  dvid_flush()  function  is  provided  to
  513.          perform that  operation.  I will refer to the "internal" cursor,
  514.          and the "screen" cursor  in  the  following  discussions.    The
  515.          internal cursor is the position which will be next written.  The
  516.          screen  cursor  is  the  actual  onscreen  cursor, whether it is
  517.          actually visible or not.
  518.                  All of the dvid functions which take a row/col value and
  519.          a  character  or  string  argument,  such   as   dvid_say()   or
  520.          dvid_char_at(),  will  call  dvid_flush()  at  the  end  of  the
  521.          operation to update the screen cursor  to  the  internal  cursor
  522.          position.    However,   the   lower   level  functions  such  as
  523.          dvid_putchr() will NOT automatically update the screen cursor to
  524.          the internal cursor.   Normally,  dvid_flush()  is  only  called
  525.          after  a  block  of  text  is  written  and  it is necessary for
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.        MicroFirm Function Library for Microsoft C & Quick C          Page 6
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.          cosmetic reasons to show where the cursor "really" is.  Since it
  541.          uses  rom-bios  functions,  using  dvid_flush()  sparingly  will
  542.          increase overall screen display speed.
  543.                  The function dvid_move() is used  to  set  the  internal
  544.          cursor position  to a new location.  Note that the screen cursor
  545.          is NOT affected by a call to dvid_move().
  546.  
  547.                        E. Writing Characters and Attributes
  548.                  When writing with normal DOS functions to  the  standard
  549.          output  channel, no concern is ever made about screen attributes
  550.          or colors.  However, when writing directly to video  memory,  it
  551.          is actually necessary to write out two bytes for each character;
  552.          one is  the  character,  the  second is the attribute.  The dvid
  553.          system saves an  attribute  internally  which  is  automatically
  554.          written each  time  a  character is written to video memory.  At
  555.          initialization, the attribute defaults to normal white on black.
  556.          The  dvid_attrib()  function  is  used  to  change  the  default
  557.          attribute  to  any  valid  attribute  for the video mode in use.
  558.          Refer to the file screen.h for a mnemonic list of screen  colors
  559.          and attributes.
  560.                  The  primary  function  for  placing  characters  to the
  561.          screen is dvid_putchr(), although  in  practice  dvid_say()  and
  562.          dvid_char_at()  may  actually be more useful. dvid_putchr() will
  563.          properly place all 256  possible  character  values  with  these
  564.          exceptions:
  565.                07H      Sounds Bell
  566.                08H      Backspaces unless internal cursor is in column 0
  567.                09H      moves internal cursor right to next mod-8 column
  568.                         (horizontal TAB)
  569.                0AH      moves internal cursor down 1 row
  570.                         (linefeed)
  571.                         If internal cursor is already at bottom of screen,
  572.                         screen scrolls up by 1 line
  573.                0DH      moves internal cursor to column 0 of current line
  574.                         (carriage return)
  575.                0BH      moves internal cursor up one line, unless cursor is
  576.                         already on line 0
  577.                         (vertical TAB)
  578.                7FH      (delete) is ignored
  579.                All other characters below 20H (space) are ignored
  580.          A  new  feature of version 1.50 allows all control characters to
  581.          be displayed  directly.    The  dvid_raw()   function   controls
  582.          handling of  these  special  characters.    Called  with  a TRUE
  583.          argument, all dvid functions  will  display  control  characters
  584.          literally.   Called with a FALSE argument restores the operation
  585.          listed above.
  586.  
  587.                            F.  Miscellaneous Operations
  588.                  There are a number of other functions to aid  in  screen
  589.          management.   As  noted above, a screen attribute can be set and
  590.          altered at will.  The function dvid_getattr()  will  return  the
  591.          value  of  the  current  attribute in use, and the current video
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.        MicroFirm Function Library for Microsoft C & Quick C          Page 7
  600.  
  601.  
  602.  
  603.  
  604.  
  605.          page selected  for  writing.    In  order  to  erase characters,
  606.          dvid_e2eol() is provided to erase from cursor to  end  of  line,
  607.          and dvid_e2eos()  erases  from cursor to end of screen.  In each
  608.          case, the cursor position used is the internal cursor,  and  the
  609.          screen cursor  is  updated automatically to match.  To clear the
  610.          entire screen, do:
  611.  
  612.             dvid_move(0,0);     /* cursor to upper left corner */
  613.             dvid_e2eos();       /* erase from 0,0 to end of screen */
  614.               - or -
  615.             dvid_cls();         /* performs a direct screen clear &
  616.                                    home cursor */
  617.  
  618.                  The CGA video card must be written  to  (or  read  from)
  619.          only at certain times to prevent video "snow".  Monochrome cards
  620.          do not  have  this  problem.   Normally, all dvid functions will
  621.          automatically synchronize with the CGA card  to  suppress  snow.
  622.          However,  it is possible to turn synchronization on and off with
  623.          the dvid_sync() function.  An argument of 0  (FALSE)  will  turn
  624.          sync  off,  and  a  non-zero  argument  (TRUE) will turn sync on
  625.          (default condition).  Why turn sync off?  Well, some  EGA  cards
  626.          do  not  produce  snow, so that sync is not needed when they are
  627.          used in CGA mode.  Or, in some cases, the extra speed of writing
  628.          without sync may be preferable to a  little  video  snow.    The
  629.          function is provided so that full flexibility is possible.
  630.                  dvid_scroll() is a function which uses rom-bios features
  631.          to scroll  a  region of the current screen up or down.  Refer to
  632.          the detailed description for this function for an explanation of
  633.          its arguments.
  634.                  If dvid_init() cannot  properly  initialize  itself,  it
  635.          sets  an  internal  flag which then forces the dvid functions to
  636.          use only rom-bios  video  functions.    This  slows  down  video
  637.          access, but  provides compatibility for oddball video cards.  As
  638.          a backup to this, the dvid_bios() function can be  called  AFTER
  639.          dvid_init() to  force the use of bios.  Note that once selected,
  640.          there is no way to turn bios off without calling dvid_done() and
  641.          re-initializing the entire video system.
  642.                  It is possible to change the attributes on a section  of
  643.          the screen  by  using  the dvid_chgattrib().  Parameters are the
  644.          starting row and column, the ending  row  and  column,  and  new
  645.          attribute.   If  using  a  CGA  card,  synchronization  will  be
  646.          performed unless it has been turned off  with  dvid_sync(FALSE).
  647.          Note  that  rom-bios  functions  will  NOT  be  used  with  this
  648.          function.  Therefore, this function MAY fail if used on  a  card
  649.          which  does  not  map video into the "normal" areas, even though
  650.          the use-bios flag has been set.
  651.  
  652.                              G.  Video Page Switching
  653.                  dvid_setpage() may be used to control the video page  in
  654.          use,  if a CGA card is being used. (MDA card video paging is not
  655.          supported.) If a CGA card is used in 80 column mode, there are 4
  656.          video pages in memory, numbered 0-3.  For 40 column mode,  there
  657.          are 8 pages, 0-7. dvid_setpage() takes two arguments.  The first
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.         MicroFirm Function Library for Microsoft C & Quick C          Page 8
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.          is the video page to select for all write/read operations.   The
  678.          second argument is FALSE to select the video page for write/read
  679.          only, and  TRUE to also select for display.  Using this function
  680.          judiciously it  is  possible  to  write  to  a  video  page  not
  681.          currently   being  displayed,  and  then  switch  to  that  page
  682.          instantly.  This can be done as follows:
  683.  
  684.          dvid_setpage(0, TRUE);  /* select page 0 for write and display */
  685.          dvid_setpage(1, FALSE); /* select page 1 for writing, but do
  686.                                     not change currently displayed page */
  687.          dvid_say(10, 5, "Hello World");  /* write to page 1 */
  688.          dvid_setpage(1, TRUE);      /* make page 1 display now */
  689.  
  690.          One caution is necessary when switching  video  pages.    It  is
  691.          HIGHLY  recommended  that  you  insure  a  full return to page 0
  692.          before exiting the program.  Leaving the system on  a  different
  693.          page often prevents subsequent programs from working properly.
  694.  
  695.                           H.  Reading from Video Memory
  696.                  Although  few programs will ever need to read what is on
  697.          the screen, there is support in The Microfirm Function Library to
  698.          accomplish  this.   The  dvid_getchr()  function  will  read  the
  699.          character and video attribute at a specified row/column position.
  700.          Synchronization will be active or  inactive as  for writing,  and
  701.          the page selected for writing will be the page used for reading.
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.        MicroFirm Function Library for Microsoft C & Quick C          Page 9
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.          VII. THE UTILITIES
  744.  
  745.          The MicroFirm Function Library comes  with   several  utilities,
  746.          including the C source code.  Nothing earth shaking  here,  just
  747.          some convenient  programs to make life a little easier.  All the
  748.          programs  use functions from The MicroFirm Function Library, and
  749.          can  serve  as  an  example  of  proper  usage.  Here is a short
  750.          description of each utility:
  751.  
  752.                                       INPATH
  753.  
  754.                  This utility searches for an EXECUTABLE program  in  the
  755.          current path.   Typing INPATH at the DOS prompt will display the
  756.          version number and a short usage message.  To use, type:
  757.  
  758.                inpath <filename>
  759.  
  760.          where filename is the basename portion of the executable file to
  761.          find.  Note that an  extension  can  be  specified,  but  it  is
  762.          ignored.   INPATH  will  first  look for the file in the current
  763.          directory, and then look in the PATH environment variable (if it
  764.          is present) in the order specified.  For each directory,  INPATH
  765.          first tries to locate a .COM file, then a .EXE file, then a .BAT
  766.          file,  since  that is the order in which DOS searches for files.
  767.          On the first  match,  INPATH  reports  the  directory  and  full
  768.          filename of the program and then exits.  If none are found, that
  769.          fact is reported.
  770.  
  771.  
  772.                                      TEXTCOMP
  773.  
  774.                  This  is  a  quick  Text  Compare program to compare two
  775.          ASCII files.  Typing TEXTCOMP at the DOS prompt will display the
  776.          version number and a short usage message.  To use, type:
  777.  
  778.                textcomp file1 file2
  779.  
  780.          where file1 and file2 are the two files  to  compare.    If  the
  781.          files are  identical,  no more messages will appear.  Otherwise,
  782.          the program will report any lines which are different  with  the
  783.          filename, line  number,  and  a printout of the actual line.  If
  784.          one file ends before the other, the program reports  which  file
  785.          terminated first.
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.        MicroFirm Function Library for Microsoft C & Quick C          Page 10
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.                                         WC
  806.  
  807.                  WC counts words, lines, characters, and checksums one or
  808.          more files.  Typing WC  at  the  DOS  prompt  will  display  the
  809.          version number and a short usage message.  To use, type:
  810.  
  811.                 wc filename [-wcls]
  812.  
  813.          where filename  is  the  name  of the file to act upon.  With no
  814.          options, the program will report words, characters, lines, and a
  815.          checksum, which is a simple binary  addition  of  all  character
  816.          values.   No,  it ain't a CRC, but it is a quick check to see if
  817.          it the same as another file under the same name.    The  options
  818.          [wcls] tell the program to report ONLY the items specified:
  819.  
  820.               -w     report only words
  821.               -l     report only lines
  822.               -c     report only characters
  823.               -s     report only checksum
  824.  
  825.          Note that giving all options is the same as giving no options.
  826.  
  827.          Since words, lines, and characters are meaningless in a non-text
  828.          file,  the  program examines the filename extension to determine
  829.          if the file is a binary or text file.    This  isn't  a  perfect
  830.          method, but  it  is good enough.  If the file extension is .COM,
  831.          .EXE, .OBJ, .REL, .PFS, .LIB, or .BIN, then only the checksum is
  832.          reported, overriding all other options.   The  program  supports
  833.          wildcards in the filename, as well as drives and directories.
  834.  
  835.  
  836.                                        GTOD
  837.  
  838.                  This  utility  will  report  the current system time and
  839.          date in a variety of formats.   GTOD  may  be  invoked  with  or
  840.          without options.  Options may be preceded by dash, fraction bar,
  841.          or nothing at all.
  842.  
  843.                 gtod <options>
  844.  
  845.               -d     report only date
  846.               -t     report only time
  847.               -e     report date in European format (DD/MM/YY)
  848.               -s     report seconds, if time reporting enabled
  849.               -r     reverse reporting order, with time first and date second
  850.               -l     spell out month in long format
  851.               -n     if option -l, then add name of weekday
  852.               -m     report time in 24 hour (military) format
  853.               -v     report version number
  854.               -?     usage message and exit
  855.               no options defaults to -dt
  856.          Output may be redirected to a file or another device, except for
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.        MicroFirm Function Library for Microsoft C & Quick C          Page 11
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.          error messages.
  877.  
  878.          GTOD  demonstrates  the  system  clock  interface,  as  well  as
  879.          error(),   monthis(),   wkdayname(),  i_dstr(),  and  weekday().
  880.          Program idea: allow calculation for other time zones.
  881.  
  882.  
  883.                                        DUMP
  884.  
  885.                  This program will dump any  file  to  the  screen  in  a
  886.          "debugging"  display  format,  in  color if it senses a CGA card
  887.          installed, or with blinks and  highlights  if  a  mono  card  is
  888.          sensed.  The  direct  video  access functions are used.  It will
  889.          optionally highlight any selected byte whenever it is found, and
  890.          it displays only 20 lines at a time and waits for a keypress  to
  891.          continue.  Invoke the program as follows:
  892.  
  893.                 dump filename -soffset -hbyte -r
  894.  
  895.          where  filename  is  the  file to dump, offset is the hex offset
  896.          value in which to index into the file before  dumping  (defaults
  897.          is  0000), and byte is the hex value to highlight (default is no
  898.          highlight).  The parameters may be in any order.  The -r  option
  899.          is  used to modify the "ascii" display in the rightmost columns.
  900.          When not used, any non-printable ASCII character is displayed as
  901.          a period.  When used, all characters are displayed.
  902.  
  903.          DUMP demonstrates the use of getkey(),  stuff(),  error(),  plus
  904.          the direct video functions of this library, and the use of color
  905.          attributes.
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.        MicroFirm Function Library for Microsoft C & Quick C          Page 12
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.          VIII. REBUILDING LIBRARIES
  942.  
  943.                  If you want to remake the entire library from the source
  944.          files,  the procedure has been automated with  a  batch file and
  945.          a make file.
  946.  
  947.                  You will need, besides Microsoft C or Quick C of course,
  948.          Microsoft's MASM, NMAKE, and LIB.  The batch file to rebuild any
  949.          library module or the entire library is  BUILD.BAT  and is self-
  950.          prompting.
  951.  
  952.                  To remake the libraries, you will most likely need to be
  953.          on a hard disk.  A dual floppy system can't handle it all in one
  954.          chunk.  If you have a floppy system, you will have to remake the
  955.          library in pieces, bringing in only a  few  source  files  at  a
  956.          time.  On a hard drive, make a subdirectory and copy into it all
  957.          source  and  header  files,  plus  the  BUILD.BAT  and  MAKEFILE
  958.          files from The MicroFirm Function Library's distribution disk.
  959.  
  960.                  Then,  making  sure  that  CL.EXE or QCL.EXE,  MASM.EXE,
  961.          NMAKE.EXE, and LIB.EXE are in your current PATH, simply  execute
  962.          "BUILD.BAT LIBS m c" where "m" is the memory model and "c" is an
  963.          optional  switch  ("Q")  when  used  with  Quick  C.  They  will
  964.          recompile and reassemble each source files and then create a new
  965.          library  file from the OBJ files.  The rebuilt library file will
  966.          be placed into the directory specified by the "LIB"  environment
  967.          variable.  Afterwards,  you may delete everything in the working
  968.          directory.  BUILD.BAT  and  MAKEFILE are only supplied with full
  969.          source registration.
  970.  
  971.                  To replace only selected functions in  the  library,  as
  972.          after a modification, use "BUILD xxx.OBJ m c" where "xxx" is the
  973.          module name without its .C or .ASM extension and "m" and "c" are
  974.          as described above. Be sure to update all five libraries.
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.        MicroFirm Function Library for Microsoft C & Quick C          Page 13
  996.  
  997.  
  998.  
  999.          X. SHAREWARE AND ONLINE HELP
  1000.  
  1001.                  Shareware  is  "try-before-you-buy" software, reasonably
  1002.          priced and user-supported.  This simply means that you  can  get
  1003.          trial  copies  of shareware from anyone who has a copy, or often
  1004.          from bulletin board systems.  If you use and like  the  program,
  1005.          then  the  author  asks that you register (purchase) the program
  1006.          for an amount usually much smaller than an equivalent commercial
  1007.          program.  By registering you will often also receive  notice  of
  1008.          available upgrades  or supplemental programs.  Keep in mind that
  1009.          the purchase of a program from a public  domain  distributor  or
  1010.          payment  to  an  online  service  (such  as CompuServe) does NOT
  1011.          constitute registration of the program since the producer of the
  1012.          program does NOT receive one penny of that payment.    Shareware
  1013.          is  NOT  public  domain software, and continued use of a program
  1014.          carries with it the OBLIGATION to purchase  the  program.    The
  1015.          free  distribution  method  is  intended  only  as  a  means  of
  1016.          obtaining a copy to evaluate before purchasing.
  1017.  
  1018.                  The MicroFirm Function Library is a  shareware  program.
  1019.          If  you use it, please complete the order form enclosed with the
  1020.          distribution.  You will be placed on  a  mailing  list  for  any
  1021.          future upgrade notices, and will be registered as a user of this
  1022.          product.   You  will  also  receive  a set of diskettes with the
  1023.          latest version, plus the H, C, M, and L model libraries, and all
  1024.          source code.    Online  help  is  available  via BIX (bob.stout)
  1025.          to registered users ONLY.
  1026.  
  1027.                  Help is  also  available  by mail.  I will try to answer
  1028.          all letters within 48 hours.  Non-registered users must  include
  1029.          a SASE   for   a   reply.     The  degree  of  help  offered  to
  1030.          non-registered users is purely discretionary.  No  phone  calls,
  1031.          please.  (Users outside the U.S. cannot, of course, send a SASE.
  1032.          I will excuse you from this requirement.)
  1033.  
  1034.                  The  Small   model  library,  documentation  files,  and
  1035.          utilities  of  The  MicroFirm  Function  Library  may  be freely
  1036.          exchanged or given away.  (This is all the files on Disk #1 of a
  1037.          distribution  set.)    However, they  may  not  be  included  or
  1038.          "bundled" with any software which is sold  or  is  a  commercial
  1039.          product  without  prior  permission.  No charge may be made  for
  1040.          copying or transferring the  files,  except that PC Users groups
  1041.          and PD/Shareware distributors  (such as PC-SIG, or Nelson Ford's
  1042.          Public Software Library) may charge  a nominal fee not to exceed
  1043.          $6.00 ($12.00 outside the U.S.). (Please request a complementary
  1044.          copy of the latest release  rather  than use a copy from another
  1045.          user.  This  insures  that  you have the most accurate copy, and
  1046.          that you  will be on my list for future updates.)
  1047.  
  1048.                  The MicroFirm Function Library and its documentation may
  1049.          not  be transferred nor exchanged in any modified form.  If  you
  1050.          really want  to "hack" the source or the documentation,  by  all
  1051.          means do so; but don't give the hacked version to anyone else. I
  1052.          cannot be expected to help  others use this product if it is not
  1053.          the same as it was when distributed.  Under no circumstances may
  1054.          the copyright  notices be altered or removed from the product or
  1055.          this documentation.
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.        MicroFirm Function Library for Microsoft C & Quick C          Page 17
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.                  If  you  decide not to use this product, then just erase
  1074.          it or pass it on to someone else.  If  you  do  use  it,  please
  1075.          honor   your   obligation   and   send   in  your  registration.
  1076.          Inexpensive shareware cannot continue to exist if those who  use
  1077.          it  treat  it  as a gift, rather than as a product for which the
  1078.          author must receive payment.  Shareware used  regularly  without
  1079.          payment  is  piracy just as much as illegally copying "Lotus" or
  1080.          any other commercial product.  Ignore the claims by some  people
  1081.          that  shareware,  because  of  its  unique  distribution method,
  1082.          carries no obligation to the regular user.    These  claims  are
  1083.          false,  and  discourage  many  good  programs  from remaining as
  1084.          shareware.
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.        MicroFirm Function Library for Microsoft C & Quick C          Page 18
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.          XI. WARRANTY and CREDITS
  1140.                  Oh,  this  shouldn't  be  necessary  among  friends  and
  1141.          gentlemen, but it's really the lawyers who  run  the  world  and
  1142.          they say we gotta do this:
  1143.  
  1144.  
  1145.               ** The  MicroFirm  Function  Library functions and all
  1146.               documentation are copyright 1988-89 by Robert B. Stout
  1147.               and/or copyright 1986, 1987 by Steven E. Margison.
  1148.  
  1149.               **  These functions and documentation are provided "as
  1150.               is" without warranty of any kind, either expressed  or
  1151.               implied,  including  but  not  limited  to the implied
  1152.               warranties  of  merchantability  and  fitness  for   a
  1153.               particular purpose.
  1154.  
  1155.               ** The user of these functions and documentation agree
  1156.               to  hold  the  author  and/or  distributor(s)  of this
  1157.               material harmless  for  any  direct  or  consequential
  1158.               damages resulting  from  its  use.    In  other words,
  1159.               "you're on your own!"
  1160.  
  1161.               ** IBM is  a  registered  trademark  of  International
  1162.               Business Machines Corporation.
  1163.  
  1164.               ** MS-DOS is a trademark of MicroSoft Corporation.
  1165.  
  1166.               ** Microsoft C  and  Quick C are registered trademarks
  1167.               of Microsoft, Inc.
  1168.  
  1169.               ** Zortech C and Zortech C++ are registered trademarks
  1170.               of Zortech, Inc.
  1171.  
  1172.               **  Turbo-C  is  a  registered  trademark  of  Borland
  1173.               International, Inc.
  1174.  
  1175.               ** Other registered trademarks may be used herein  and
  1176.               are acknowledged.
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.        MicroFirm Function Library for Microsoft C & Quick C          Page 19
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.          =======================================================================
  1206.                       SOFTWARE REGISTRATION FORM AND ORDER
  1207.          =======================================================================
  1208.          A separate form must be filled out for each product ordered or
  1209.          registered.  This form may be photocopied, printed out, or
  1210.          edited to include all information and re-printed.
  1211.  
  1212.          PRODUCT: -------- MicroFirm Microsoft LIBRARY VERSION 1.01 ------------
  1213.  
  1214.          QUANTITY:                                                Amount:
  1215.  
  1216.          _____  Registration with Source code        $25.00 ea    $______
  1217.          _____  Update from MFLZT or SMTC            $10.00 ea    $______
  1218.          _____  Additional Zortech C version         $10.00 ea    $______
  1219.  
  1220.               Shipping outside U.S. or Canada        $ 3.00       $______
  1221.               Surcharge for non-U.S. Funds           $ 5.00       $______
  1222.  
  1223.                                   TOTAL DUE                       $______
  1224.  
  1225.          Source code is NOT SHAREWARE and is not to be transferred to other
  1226.          users.  Only the DOC files, header files, utilities,
  1227.          and S library are released into shareware.
  1228.  
  1229.          Corporations:  Write with your requirements for a quote on
  1230.                         multiple copies or site licensing.
  1231.  
  1232.          If you already have this library, where was it obtained?
  1233.          [ ]BIX  [ ]Friend  [ ]Employer  [ ]BBS:__________________
  1234.          Version_____ Serial No._________
  1235.  
  1236.          If updating from SMTC:    Version_____ Serial No._________ 
  1237.  
  1238.          Payment is by check[ ] or money order[ ] (Sorry - no COD or charges)
  1239.  
  1240.          NAME _______________________________________________________
  1241.  
  1242.          COMPANY ____________________________________________________
  1243.  
  1244.          ADDRESS ____________________________________________________
  1245.  
  1246.          CITY _______________________________________________________
  1247.  
  1248.          STATE___________________________ ZIP _______________________
  1249.  
  1250.          =======================================================================
  1251.          Send completed form and payment to:
  1252.                                  MicroFirm
  1253.                                 P.O. Box 428
  1254.                                Alief, TX 77411
  1255.          =======================================================================
  1256.                        - do not write below this line -
  1257.  
  1258.          recd________   sent________ version_______ serial no.__________________
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.